;Explorer PC by Pablo Corro Cortez
;http://www.geocities.com/xxideveloper
;email:pablocortez@hotmail.com
.186
on         EQU 1
off	   EQU 0
white	   EQU 0fh
black	   EQU 00h
blue_light EQU 66h
blue_push  EQU 4eh
blue	   EQU 37h
dark_blue  EQU 1
gray	   EQU 1dh
light_gray EQU 1eh
green_light EQU 7ch
dark_gray  EQU 1ah
include data.asm
include vesa101h.asm
include system.asm
stacksegment segment stack
	     dw 256 dup(0)
stacksegment ENDs
codesegment segment "CODE"
        assume cs:codesegment,ds:datasegment
start:  mov ax,datasegment
        mov ds,ax
        call initialize
	mov win_color,light_gray
	call clrscr
        ;DRAW RECTANGLES
	mov win_color,blue_push
	mov win_relative_x1,0
	mov win_relative_y1,0
	mov win_relative_x2,639
	mov win_relative_y2,16
	call fillrectangle
	mov win_color,white
	mov win_relative_x1,1
	mov win_relative_y1,103
	mov win_relative_x2,214
	mov win_relative_y2,456
	call fillrectangle
	mov win_relative_x1,222
	mov win_relative_y1,103
	mov win_relative_x2,637
	mov win_relative_y2,456
	call fillrectangle
        mov win_color,green_light
	mov win_relative_x1,0
	mov win_relative_y1,459
	mov win_relative_x2,639
	mov win_relative_y2,479
	call fillrectangle
	; DRAW LINES
	mov win_color,dark_gray
	mov win_relative_x1,0
	mov win_relative_y1,18
	mov win_relative_x2,638
	call draw_hhline
	mov win_relative_x1,0
	mov win_relative_y1,18
	mov win_relative_y2,81
	call draw_vvline
	mov win_relative_x1,638
	mov win_relative_y1,18
	mov win_relative_y2,81
	call draw_vvline
	mov win_relative_x1,0
 	mov win_relative_y1,81
	mov win_relative_x2,638
	 call draw_hhline
	mov win_relative_x1,2      ;medium
	mov win_relative_y1,39
	mov win_relative_x2,638
	call draw_hhline
	mov win_color,WHITE
	mov win_relative_x1,1
	mov win_relative_y1,19
	mov win_relative_x2,637
	call draw_hhline
	mov win_relative_x1,1
	mov win_relative_y1,19
	mov win_relative_y2,80
	call draw_vvline
	mov win_relative_x1,639
	mov win_relative_y1,19
	mov win_relative_y2,80
	call draw_vvline
	mov win_relative_x1,1
	mov win_relative_y1,40      ;medium
	mov win_relative_x2,637
	call draw_hhline
	mov win_relative_x1,0
	mov win_relative_y1,82
	mov win_relative_x2,637
	 call draw_hhline
	; ----- lines for directories
	mov win_color,dark_gray
	mov win_relative_x1,0
	mov win_relative_y1,84
	mov win_relative_x2,215
	call draw_hhline
	mov win_relative_x1,0
	mov win_relative_y1, 458
	mov win_relative_x2,215
	call draw_hhline
	mov win_relative_x1,0
	mov win_relative_y1,84
	mov win_relative_y2,457
	call draw_vvline
	mov win_relative_x1,215
	mov win_relative_y1,84
	mov win_relative_y2,457
	call draw_vvline
	mov win_relative_x1,2
	mov win_relative_y1,102
	mov win_relative_x2,215
	call draw_hhline
	mov win_color,white
	mov win_relative_x1,1
	mov win_relative_y1,85
	mov win_relative_x2,214
	call draw_hhline
	mov win_relative_x1,1
	mov win_relative_y1,85
	mov win_relative_y2,104
	call draw_vvline
	mov win_relative_x1,0
	mov win_relative_y1, 459
	mov win_relative_x2,639
	call draw_hhline
	mov win_relative_x1,216
	mov win_relative_y1,84
	mov win_relative_y2,458
	call draw_vvline
	; ----- lines for files
	mov win_color,dark_gray
	mov win_relative_x1,221
	mov win_relative_y1, 84
	mov win_relative_x2,638
	call draw_hhline
	mov win_relative_x1,221
	mov win_relative_y1,458
	mov win_relative_x2,638
	call draw_hhline
	mov win_relative_x1,221
	mov win_relative_y1,84
	mov win_relative_y2,457
	call draw_vvline
	mov win_relative_x1,221
	mov win_relative_y1,102
	mov win_relative_x2,638
	call draw_hhline
	mov win_relative_x1,638
	mov win_relative_y1,84
	mov win_relative_y2,457
	call draw_vvline

	mov win_color,white
	mov win_relative_x1,639
	mov win_relative_y1,84
	mov win_relative_y2,458
	call draw_vvline
	mov win_relative_x1,222
	mov win_relative_y1,85
	mov win_relative_x2,637
	call draw_hhline
	mov win_relative_x1,222
	mov win_relative_y1,85
	mov win_relative_y2,102
	call draw_vvline
	; DRAW ICONS
	mov win_relative_x1,2
	mov win_relative_y1,1
	mov win_icon_addr,offset file_ico
	call draw_icon
	mov win_relative_x1,623
	mov win_relative_y1,1
	mov win_icon_addr,offset ex1_ico
	call draw_icon
	mov win_relative_x1,23
	mov win_relative_y1,46
	mov win_icon_addr,offset back
	call draw_icon
	mov win_relative_x1,91
	mov win_relative_y1,46
	mov win_icon_addr,offset forw
	call draw_icon
	mov win_relative_x1,152
	mov win_relative_y1,46
	mov win_icon_addr,offset up
	call draw_icon
	mov win_relative_x1,217
	mov win_relative_y1,45
	mov win_icon_addr,offset cut
	call draw_icon
	mov win_relative_x1,277
	mov win_relative_y1,45
	mov win_icon_addr,offset copy
	call draw_icon
	mov win_relative_x1,341
	mov win_relative_y1,45
	mov win_icon_addr,offset paste
	call draw_icon
	mov win_relative_x1,406
	mov win_relative_y1,45
	mov win_icon_addr,offset properties
	call draw_icon
	mov win_relative_x1,470
	mov win_relative_y1,47
	mov win_icon_addr,offset delete
	call draw_icon
	mov win_relative_x1,529
	mov win_relative_y1,46
	mov win_icon_addr,offset reload
	call draw_icon
	; WRITE TEXT
	mov win_color,black
	mov win_relative_x1,22
	mov win_relative_y1,26
	mov win_string_addr,offset sysfile
	call Write_Pascal_String
	mov win_relative_x1,63
	mov win_string_addr,offset sysedit
	call Write_Pascal_String
	mov win_relative_x1,104
	mov win_string_addr,offset systools
	call Write_Pascal_String
	mov win_relative_x1,11
	mov win_relative_y1,69
	mov win_string_addr,offset sysbackward
	call Write_Pascal_String
	mov win_relative_x1,78
	mov win_string_addr,offset sysforward
	call Write_Pascal_String
	mov win_relative_x1,156
	mov win_string_addr,offset sysup
	call Write_Pascal_String
	mov win_relative_x1,216
	mov win_string_addr,offset syscut
	call Write_Pascal_String
	mov win_relative_x1,276
	mov win_string_addr,offset syscopy
	call Write_Pascal_String
	mov win_relative_x1,338
	mov win_string_addr,offset syspaste
	call Write_Pascal_String
	mov win_relative_x1,390
	mov win_string_addr,offset sysproperties
	call Write_Pascal_String
	mov win_relative_x1,464
	mov win_string_addr,offset sysdelete
	call Write_Pascal_String
	mov win_relative_x1,521
	mov win_string_addr,offset sysreload
	call Write_Pascal_String
	mov win_relative_x1,9
	mov win_relative_y1,91
	mov win_string_addr,offset sysdirectories
	call Write_Pascal_String
	mov win_color,7fh
	mov win_relative_x1,551
	mov win_relative_y1,468
	mov win_string_addr,offset systitle
	call Write_Pascal_String
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
call exploring_mypc
   push es
   mov ax,datasegmentdirectory
   mov es,ax
   mov ah,19h ;get default drive
   int 21h
   add al,65
   mov ah,al
   mov cx,struc_dir_elements_count
   dec cx
   mov di,9
   mov al,1
   _bucle:
   cmp ah,es:[di+4]
   je _ok
   mov bl,es:[di+3]
   xor bh,bh
   add bx,4
   add di,bx
   inc al
   loop _bucle
   _ok:
   pop es
   mov bl,16
   mul bl
   add ax,110
   mov directory_mouseY,ax
   mov directory_mouseX,22
   call draw_directories
   call get_directory_from_The_mouse
   mov directory_mouseX,62
   call get_directory_from_The_mouse
exploring:
call mouse_update_all_values
call mouse_update_files_wheel
; * * * into exit button ?
	cmp mouse_struc_current,1
	je intoexitbutton
	   cmp exit_sw1,1
	   jne exit_pressed_out
	       mov exit_sw1,0
	       mov win_icon_addr,offset ex1_ico
	       jmp a000
	intoexitbutton:
	cmp exit_sw1,1
	jne exitout
            cmp mouse_updated_button_left,on
	    je exit_pressed_out
	    mov win_relative_x1,623
	    mov win_relative_y1,1
	    mov win_icon_addr,offset ex1_ico
	    call draw_icon;?
	    call terminate
	    mov ah,4ch
	    int 21h
        exitout:
        cmp mouse_updated_button_left,on
	jne exit_pressed_out
	mov exit_sw1,1
	mov win_icon_addr,offset ex2_ico
   a000:mov win_relative_x1,623
	mov win_relative_y1,1
	call draw_icon
        exit_pressed_out:
; * * * into icons area ?  code for 9 icons
	mov ax,2
	into_icons_bucle:
	push ax
	mov cx,ax
	dec ax
	dec ax
	mov bl,34
	mul bl
	add ax,offset icons_array
	mov bx,ax  ; then the icon information offset--> bx
	cmp mouse_struc_current,cl
	jne b222
	jmp intobutton
	b222:
	   cmp byte ptr [bx+2],1 ;sw3
	   jne b777
	   mov al,byte ptr mouse_internal_status
	   rcr al,1
	   jc b777
	   mov byte ptr [bx+2],0 ;sw3
	   b777:
	   cmp byte ptr [bx],1 ;sw1
	   je b101
	   cmp byte ptr [bx+1],1 ;sw2
	   je b101	   
	   jmp pressed_out
	   b101:mov al,byte ptr [bx+1] ;sw2
		mov byte ptr [bx+2],al ;sw3
		mov byte ptr [bx],0 ;sw1
		mov byte ptr [bx+1],0 ;sw2
		mov win_color,light_gray
		mov ax,word ptr [bx+5] ;x1
		mov win_relative_x1,ax
		mov win_relative_y1,41
		mov ax,word ptr [bx+7] ;x2
		mov win_relative_x2,ax
		mov win_relative_y2,80
		call fillrectangle
		mov ax,word ptr [bx+13] ;x1 icon
		mov win_relative_x1,ax
		mov ax,word ptr [bx+15] ;y1 icon
		mov win_relative_y1,ax
		mov ax,word ptr [bx+28] ;icon offset
		mov win_icon_addr,ax
		call draw_icon
		mov win_color,black
		mov ax,word ptr [bx+9] ;x1 txt
		mov win_relative_x1,ax
		mov ax,word ptr [bx+11] ;y1 txt
		mov win_relative_y1,ax
		mov ax,bx ;txt offset
		add ax,17
		mov win_string_addr,ax
		call Write_Pascal_String
		jmp pressed_out
	intobutton:
	cmp byte ptr [bx],1 ;sw1
	je b007
	jmp b001
	   b007:cmp mouse_updated_button_left,on
		je b008
		mov byte ptr [bx+4],0 ;sw5
		cmp byte ptr [bx+1],1 ;sw2
		jne b006
		mov byte ptr [bx+1],0 ;sw2
		mov byte ptr [bx+3],1 ;sw4
		jmp b016
	   b006:jmp pressed_out
	   b008:cmp byte ptr [bx+4],1 ;sw5
		je b006
		cmp byte ptr [bx+1],1 ;sw2
		je b006
		mov byte ptr [bx+1],1 ;sw2
	   b033:mov win_color,light_gray
		mov ax,word ptr [bx+5] ;x1
		mov win_relative_x1,ax
		mov win_relative_y1,41
		mov ax,word ptr [bx+7] ;x2
		mov win_relative_x2,ax
		mov win_relative_y2,80
		call fillrectangle
		mov ax,word ptr [bx+13] ;icox1
		inc ax
		mov win_relative_x1,ax
		mov ax,word ptr [bx+15] ;icoy1
		inc ax
		mov win_relative_y1,ax
		mov ax,word ptr [bx+28] ;icon offset
		mov win_icon_addr,ax
		call draw_icon
		mov win_color,black
		mov ax,word ptr [bx+9] ;txtx1
		inc ax
		mov win_relative_x1,ax
		mov ax,word ptr [bx+11] ;txty1
		inc ax
		mov win_relative_y1,ax
		mov ax,bx ;txt offset
		add ax,17
		mov win_string_addr,ax
		call Write_Pascal_String
		mov win_color,dark_gray
		mov ax,word ptr [bx+5] ;x1
		mov win_relative_x1,ax
		mov win_relative_y1,41
		mov ax,word ptr [bx+7] ;x2
		mov win_relative_x2,ax
		call draw_hhline
		mov ax,word ptr [bx+5] ;x1
		mov win_relative_x1,ax
		mov win_relative_y1,41
		mov win_relative_y2,80
		call draw_vvline
		mov win_color,white
		mov ax,word ptr [bx+5] ;x1
		mov win_relative_x1,ax
		mov win_relative_y1,80
		mov ax,word ptr [bx+7] ;x2
		mov win_relative_x2,ax
		call draw_hhline
		mov ax,word ptr [bx+7] ;x2
		mov win_relative_x1,ax
		mov win_relative_y1,41
		mov win_relative_y2,79
		call draw_vvline
		jmp pressed_out
   b001:mov byte ptr [bx],1 ;sw1
	cmp byte ptr [bx+2],1 ;sw3
	jne b022
	mov byte ptr [bx+2],0 ;sw3
	jmp b033
   b022:cmp mouse_updated_button_left,on
	jne b016
	mov byte ptr [bx+4],1 ;sw5
   b016:mov win_color,light_gray
	mov ax,word ptr [bx+5] ;x1
	mov win_relative_x1,ax
	mov win_relative_y1,41
	mov ax,word ptr [bx+7] ;x2
	mov win_relative_x2,ax
	mov win_relative_y2,80
	call fillrectangle
	mov ax,word ptr [bx+13] ;icox1
	mov win_relative_x1,ax
	mov ax,word ptr [bx+15] ;icoy1
	mov win_relative_y1,ax
	mov ax,word ptr [bx+28] ;icon offset
	mov win_icon_addr,ax
	call draw_icon
	mov win_color,black
	mov ax,word ptr [bx+9] ;txtx1
	mov win_relative_x1,ax
	mov ax,word ptr [bx+11] ;txty1
	mov win_relative_y1,ax
	mov ax,bx ;txt offset
	add ax,17
	mov win_string_addr,ax
	call Write_Pascal_String
	mov win_color,dark_gray
	mov ax,word ptr [bx+5] ;x1
	mov win_relative_x1,ax
	mov win_relative_y1,80
	mov ax,word ptr [bx+7] ;x2
	mov win_relative_x2,ax
	call draw_hhline
	mov ax,word ptr [bx+7] ;x2
	mov win_relative_x1,ax
	mov win_relative_y1,41
	mov win_relative_y2,79
	call draw_vvline
	mov win_color,white
	mov ax,word ptr [bx+5] ;x1
	mov win_relative_x1,ax
	mov win_relative_y1,41
	mov ax,word ptr [bx+7] ;x2
	mov win_relative_x2,ax
	call draw_hhline
	mov ax,word ptr [bx+5] ;x1
	mov win_relative_x1,ax
	mov win_relative_y1,41
	mov win_relative_y2,79
	call draw_vvline
	cmp byte ptr [bx+3],1 ;sw4
	jne pressed_out
	mov byte ptr [bx+3],0 ;sw4
	call dword ptr [bx+30]
	pressed_out:
	pop ax
	inc ax
	cmp ax,11
	jge pressed_out2
	jmp into_icons_bucle
	pressed_out2:
; * * * into directory space ?
	cmp mouse_struc_current,11
	jne j001
           cmp mouse_updated_button_left,on
	   je j005
           mov directory_sw2,1
	   j005:
           cmp directory_sw2,1
           jne directories_area_exit
           cmp directory_sw1,0
	   jne j002
              mov directory_sw1,0
              cmp mouse_updated_button_left,on
	      je j008
              mov directory_sw1,0
	      jmp directories_area_exit
	      j008:
              mov directory_sw2,1
              mov directory_sw1,1
              mov ax,mouse_updated_x
              mov directory_mouseX,ax
              mov ax,mouse_updated_y
              mov directory_mouseY,ax
	      call get_directory_from_the_mouse
	      jmp short directories_area_exit
	   j002:
           cmp mouse_updated_button_left,on
	   je directories_area_exit
           mov directory_sw1,0
	   jmp directories_area_exit
	j001:
        mov directory_sw1,0
        mov directory_sw2,0 
        cmp mouse_updated_button_left,on
	je j009
        mov directory_sw2,1
	j009:
	directories_area_exit:
; * * * into directory vertical bar ?
      cmp mouse_struc_current,12
	jne k001
           cmp mouse_updated_button_left,on
	   je k005
           mov directoryvb_sw2,1
	   k005:
           cmp directoryvb_sw2,1
           jne directoriesvb_exit
           cmp directoryvb_sw1,0
	   jne k002
              mov directoryvb_sw1,0
              cmp mouse_updated_button_left,on
	      je k008
              mov directoryvb_sw1,0
	      jmp directoriesvb_exit
	      k008:
              mov directoryvb_sw2,1
              mov directoryvb_sw1,1
	      call set_directoryvb_from_the_mouse
	      jmp short directoriesvb_exit
	   k002:
           cmp mouse_updated_button_left,on
	   je directoriesvb_exit
           mov directoryvb_sw1,0
	   jmp directoriesvb_exit
	k001:
	mov directoryvb_sw1,0
        mov directoryvb_sw2,0
        mov directoryvb_sw3,0
        cmp mouse_updated_button_left,on
	je k009
        mov directoryvb_sw2,1
	k009:
	directoriesvb_exit:
; * * * into vertical bar up button ?
	cmp mouse_struc_current,13
	je intovbupbutton
	   cmp dvbup_sw1,1
	   jne vbup_pressed_out
	       mov dvbup_sw1,0
	       mov win_icon_addr,offset icon_arrow_up1
	       jmp l000
	intovbupbutton:
	cmp dvbup_sw1,1
	jne vbupout
            cmp mouse_updated_button_left,on
	    jne l001
	    cmp win_dir_relative_starty,0
	    jbe short vbup_pressed_out
	    sub win_dir_relative_starty,16
	    call draw_directories
            jmp short vbup_pressed_out
	    l001:
	    mov win_relative_x1,199
	    mov win_relative_y1,103
	    mov win_icon_addr,offset icon_arrow_up1
	    call draw_icon
        vbupout:
        cmp mouse_updated_button_left,on
	jne vbup_pressed_out
	mov dvbup_sw1,1
	mov win_icon_addr,offset icon_arrow_up2
   l000:mov win_relative_x1,199
	mov win_relative_y1,103
	call draw_icon
        vbup_pressed_out:
; * * * into vertical bar down button ?
	cmp mouse_struc_current,14
	je intovbdownbutton
	   cmp dvbdown_sw1,1
	   jne vbdown_pressed_out
	       mov dvbdown_sw1,0
	       mov win_icon_addr,offset icon_arrow_down1
	       jmp m000
	intovbdownbutton:
	cmp dvbdown_sw1,1
	jne vbdownout
            cmp mouse_updated_button_left,on
	    jne m001
	    cmp win_dir_relative_maxY,339
	    jb vbdown_pressed_out
	    mov ax,win_dir_relative_maxY
	    sub ax,339
	    cmp ax,win_dir_relative_starty
	    jbe vbdown_pressed_out
	    add win_dir_relative_starty,16
	    call draw_directories
	    jmp short vbdown_pressed_out
	    m001:
	    mov win_relative_x1,199
	    mov win_relative_y1,427
	    mov win_icon_addr,offset icon_arrow_down1
	    call draw_icon
        vbdownout:
        cmp mouse_updated_button_left,on
	jne vbdown_pressed_out
	mov dvbdown_sw1,1
	mov win_icon_addr,offset icon_arrow_down2
   m000:mov win_relative_x1,199
	mov win_relative_y1,427
	call draw_icon
        vbdown_pressed_out:
; * * * into directory horizontal bar ?
	cmp mouse_struc_current,15
	jne n001
           cmp mouse_updated_button_left,on
	   je n005
           mov directoryhb_sw2,1
	   n005:
           cmp directoryhb_sw2,1
           jne directorieshb_exit
           cmp directoryhb_sw1,0
	   jne n002
              mov directoryhb_sw1,0
              cmp mouse_updated_button_left,on
	      je n008
              mov directoryhb_sw1,0
	      jmp directorieshb_exit
	      n008:
              mov directoryhb_sw2,1
              mov directoryhb_sw1,1
	      ;call set_directorhvb_from_the_mouse
	      jmp short directorieshb_exit
	   n002:
           cmp mouse_updated_button_left,on
	   je directorieshb_exit
           mov directoryhb_sw1,0
	   jmp directorieshb_exit
	n001:
	mov directoryhb_sw1,0
        mov directoryhb_sw2,0
        mov directoryhb_sw3,0
        cmp mouse_updated_button_left,on
	je n009
        mov directoryhb_sw2,1
	n009:
	directorieshb_exit:
; * * * into horizontal bar left button ?
	cmp mouse_struc_current,16
	je intohbleftbutton
	   cmp dhbleft_sw1,1
	   jne hbleft_pressed_out
	       mov dhbleft_sw1,0
	       mov win_icon_addr,offset icon_arrow_left1
	       jmp o000
	intohbleftbutton:
	cmp dhbleft_sw1,1
	jne hbleftout
            cmp mouse_updated_button_left,on
	    jne o001
	    cmp win_dir_relative_startx,0
	    jbe short hbleft_pressed_out
	    sub win_dir_relative_startx,7
	    call draw_directories
            jmp short hbleft_pressed_out
	    o001:
	    mov win_relative_x1,1
	    mov win_relative_y1,442
	    mov win_icon_addr,offset icon_arrow_left1
	    call draw_icon
        hbleftout:
        cmp mouse_updated_button_left,on
	jne hbleft_pressed_out
	mov dhbleft_sw1,1
	mov win_icon_addr,offset icon_arrow_left2
   o000:mov win_relative_x1,1
	mov win_relative_y1,442
	call draw_icon
        hbleft_pressed_out:
; * * * into horizontal bar right button ?
	cmp mouse_struc_current,17
	je intohbrightbutton
	   cmp dhbright_sw1,1
	   jne hbright_pressed_out
	       mov dhbright_sw1,0
	       mov win_icon_addr,offset icon_arrow_right1
	       jmp p000
	intohbrightbutton:
	cmp dhbright_sw1,1
	jne hbrightout
            cmp mouse_updated_button_left,on
	    jne p001
	    cmp win_dir_relative_maxX,198
	    jb hbright_pressed_out
	    mov ax,win_dir_relative_maxX
	    sub ax,198
	    cmp ax,win_dir_relative_startx
	    jbe hbright_pressed_out
	    add win_dir_relative_startx,7
	    call draw_directories
	    jmp short hbright_pressed_out
	    p001:
	    mov win_relative_x1,183
	    mov win_relative_y1,442
	    mov win_icon_addr,offset icon_arrow_right1
	    call draw_icon
        hbrightout:
        cmp mouse_updated_button_left,on
	jne hbright_pressed_out
	mov dhbright_sw1,1
	mov win_icon_addr,offset icon_arrow_right2
   p000:mov win_relative_x1,183
	mov win_relative_y1,442
	call draw_icon
        hbright_pressed_out:
; * * * into files space ?
        cmp mouse_struc_current,18
	jne w001
           cmp mouse_updated_button_left,on
	   je w005
           mov files_sw2,1
	   w005:
           cmp files_sw2,1
           jne files_area_exit
           cmp files_sw1,0
	   jne w002
              mov files_sw1,0
              cmp mouse_updated_button_left,on
	      je w008
              mov files_sw1,0
	      jmp files_area_exit
	      w008:
              mov files_sw2,1
              mov files_sw1,1
	      call work_element_selected_from_files_area
	      jmp short files_area_exit
	   w002:
           cmp mouse_updated_button_left,on
	   je files_area_exit
           mov files_sw1,0
	   jmp files_area_exit
	w001:
        mov files_sw1,0
        mov files_sw2,0
        cmp mouse_updated_button_left,on
	je w009
        mov files_sw2,1
	w009:
	files_area_exit:
; * * * into FILES horizontal bar ?
	cmp mouse_struc_current,23
	jne t001
           cmp mouse_updated_button_left,on
	   je t005
           mov fileshb_sw2,1
	   t005:
           cmp fileshb_sw2,1
           jne fileshb_exit
           cmp fileshb_sw1,0
	   jne t002
              mov fileshb_sw1,0
              cmp mouse_updated_button_left,on
	      je t008
            mov fileshb_sw1,0
	      jmp fileshb_exit
	      t008:
              mov fileshb_sw2,1
              mov fileshb_sw1,1
	      ;call set_fileshvb_from_the_mouse
	      jmp short fileshb_exit
	   t002:
           cmp mouse_updated_button_left,on
	   je fileshb_exit
         mov fileshb_sw1,0
	   jmp fileshb_exit
	t001:
	mov fileshb_sw1,0
      mov fileshb_sw2,0
      mov fileshb_sw3,0
      cmp mouse_updated_button_left,on
      je t009
      mov fileshb_sw2,1
	t009:
	fileshb_exit:
; * * * into FILES bar left button ?
	cmp mouse_struc_current,24
	je intoFhbleftbutton
	   cmp fhbleft_sw1,on
	   je fhb_EQ
           jmp fhbleft_pressed_out
               fhb_EQ:
	       mov fhbleft_sw1,0
	       mov win_icon_addr,offset icon_arrow_left1
	       jmp u000
	intoFhbleftbutton:
	cmp fhbleft_sw1,on
	je fhb_EQ2
            jmp fhbleftout
            fhb_EQ2:
            cmp mouse_updated_button_left,on
	    jne u001
	    cmp win_file_relative_startx,0
	    jg fhb_EQ3
            jmp fhbleft_pressed_out
            fhb_EQ3:
	    sub win_file_relative_startx,5
            mov fileshb_float_ini_x1_latest,0ffffh ;enable refresh screen
            dec mouse_struc_data_fileshbf
	    dec mouse_struc_data_fileshbf+4
            ;begin calculate new bar pos
	    mov ax,word ptr mouse_struc_data_fileshb+4 ; totalbar
	    sub ax,word ptr mouse_struc_data_fileshb
	    sub ax,fileshb_float_lenght
	    mov bx,1000
            mul bx
            mov cx,fields_to_view_lenght
            add cx,fields_to_view_lenght+2
            add cx,fields_to_view_lenght+4
            add cx,fields_to_view_lenght+6
            add cx,fields_to_view_lenght+8
            add cx,fields_to_view_lenght+10
           add cx,32
            add cx,FILES_ABSOLUTE_X1
            sub cx,FILES_ABSOLUTE_X2
            div cx
            mov cx,win_file_relative_startx
            mul cx
	    div bx
	    add ax,word ptr mouse_struc_data_fileshb
	    mov word ptr mouse_struc_data_fileshbf,ax
            add ax,fileshb_float_lenght
	    mov word ptr mouse_struc_data_fileshbf+4,ax
            ;end calculate new bar pos
            call draw_files_horizontal_bar_scroll
            call draw_files_titles
	    call draw_files
          jmp short fhbleft_pressed_out
	    u001:
	    mov win_relative_x1,222
	    mov win_relative_y1,442
	    mov win_icon_addr,offset icon_arrow_left1
	    call draw_icon
        fhbleftout:
        cmp mouse_updated_button_left,on
	jne fhbleft_pressed_out
	mov fhbleft_sw1,1
	mov win_icon_addr,offset icon_arrow_left2
   u000:mov win_relative_x1,222
	mov win_relative_y1,442
	call draw_icon
      fhbleft_pressed_out:

; * * * into FILES horizontal bar right button ?
	cmp mouse_struc_current,25
	je intoFhbrightbutton
           cmp fhbright_sw1,off
           jne fhdright_ok
	   jmp fhbright_pressed_out
               fhdright_ok:
	       mov fhbright_sw1,off
	       mov win_icon_addr,offset icon_arrow_right1
	       jmp v000
	intoFhbrightbutton:
	cmp fhbright_sw1,off
	jne fhbrightout_x
        jmp fhbrightout
            fhbrightout_x:
            cmp mouse_updated_button_left,on
	    je v009
            mov fhbright_sw1,off
            mov win_icon_addr,offset icon_arrow_right1
            jmp v000
            v009:
            mov cx,fields_to_view_lenght
            add cx,fields_to_view_lenght+2
            add cx,fields_to_view_lenght+4
            add cx,fields_to_view_lenght+6
            add cx,fields_to_view_lenght+8
            add cx,fields_to_view_lenght+10
            add cx,32
	    sub cx,win_file_relative_startx
            mov ax,FILES_ABSOLUTE_X2
            sub ax,FILES_ABSOLUTE_X1
            cmp cx,ax
	    jg fhdright_ok3
	    mov ax,mouse_struc_data_fileshbf+4
	    cmp ax,mouse_struc_data_fileshb+4
	    jb bar_right_one_pixel
	    jmp fhbright_pressed_out
	    bar_right_one_pixel:
	    inc mouse_struc_data_fileshbf
	    inc mouse_struc_data_fileshbf+4
            call draw_files_horizontal_bar_scroll
	    call draw_files
            jmp fhbright_pressed_out
            fhdright_ok3:
	    add win_file_relative_startx,5
            mov fileshb_float_ini_x1_latest,0ffffh ;enable refresh screen
            ;begin calculate new bar pos
	    mov ax,word ptr mouse_struc_data_fileshb+4 ; totalbar
	    sub ax,word ptr mouse_struc_data_fileshb
	    sub ax,fileshb_float_lenght
	    mov bx,1000
            mul bx
            mov cx,fields_to_view_lenght
            add cx,fields_to_view_lenght+2
            add cx,fields_to_view_lenght+4
            add cx,fields_to_view_lenght+6
            add cx,fields_to_view_lenght+8
            add cx,fields_to_view_lenght+10
           add cx,37 ;-+
            add cx,FILES_ABSOLUTE_X1
            sub cx,FILES_ABSOLUTE_X2
            div cx
            mov cx,win_file_relative_startx
            mul cx
	    div bx
	    add ax,word ptr mouse_struc_data_fileshb
	    mov word ptr mouse_struc_data_fileshbf,ax
            add ax,fileshb_float_lenght
	    mov word ptr mouse_struc_data_fileshbf+4,ax
            ;end calculate new bar pos
            call draw_files_horizontal_bar_scroll
            call draw_files_titles
	    call draw_files
	    jmp short fhbright_pressed_out
        fhbrightout:
        cmp mouse_updated_button_left,on
	jne fhbright_pressed_out
        mov fhbright_sw1,on
	mov win_icon_addr,offset icon_arrow_right2
   v000:mov win_relative_x1,607
	mov win_relative_y1,442
	call draw_icon
      fhbright_pressed_out:


















; * * * into FILES vertical bar up button ?
        cmp files_vertical_bar_active,on
        je fvbac
        jmp vbfloat_out
        fvbac:
	cmp mouse_struc_current,21
	je intoFvbupbutton
	   cmp fvbup_sw1,off
	   jne fvbup_out_and_off
               jmp fvbup_pressed_out
           fvbup_out_and_off:
	       mov fvbup_sw1,off
	       mov win_icon_addr,offset icon_arrow_up1
	       jmp short r000
	intoFvbupbutton:
	cmp fvbup_sw1,off
	je fvbupout
            cmp mouse_updated_button_left,on
	    je r009
            mov fvbup_sw1,off
	    mov win_icon_addr,offset icon_arrow_up1
            jmp short r000
            r009:
	    cmp win_files_start_element,0
            je fvbup_pressed_out
            dec win_files_start_element
	    sub win_file_relative_starty,16
            ;begin calculate new bar pos
	    mov ax,word ptr mouse_struc_data_filesvb+6 ; totalbar
	    sub ax,word ptr mouse_struc_data_filesvb+2
            sub ax,filesvb_float_lenght
	    mov bx,1000
            mul bx
            mov cx,struc_file_elements_count
            sub cx,FILES_ROWS
            div cx
            mov cx,win_files_start_element
            mul cx
            div bx
	    add ax,word ptr mouse_struc_data_filesvb+2
	    mov word ptr mouse_struc_data_filesvbf+2,ax
            add ax,filesvb_float_lenght
	    mov word ptr mouse_struc_data_filesvbf+6,ax
            ;end calculate new bar pos
            call draw_files_vertical_bar_scroll
	    call draw_files
            jmp short fvbup_pressed_out
        fvbupout:
        cmp mouse_updated_button_left,on
	jne fvbup_pressed_out
	mov fvbup_sw1,on
	mov win_icon_addr,offset icon_arrow_up2
   r000:mov win_relative_x1,623
	mov win_relative_y1,103
	call draw_icon
      fvbup_pressed_out:
; * * * into FILES vertical bar ?
      cmp mouse_struc_current,20
	je q001
           mov filesvb_sw1,off
	   jmp filesvb_exit
	q001:
           mov ax,FILES_ROWS
	   cmp struc_file_elements_count,ax
	   ja q002
           jmp filesvb_exit
	   q002:
           cmp mouse_updated_button_left,on
           jne fvb_1
           cmp filesvb_sw1,on
           je fvb_ok
           jmp filesvb_exit
           fvb_1:
	   mov filesvb_sw1,on
           fvb_exit2:jmp filesvb_exit
         fvb_ok:
	 ;mov filesvb_sw1,off
         mov ax,mouse_updated_y
	 cmp ax,word ptr mouse_struc_data_filesvbf+6
         ja fvb_down
	 cmp ax,word ptr mouse_struc_data_filesvbf+2
         ja fvb_exit2
         mov ax,FILES_ROWS
         sub win_files_start_element,ax
         js fvb_up_ini
         mov cl,4
         shl ax,cl  ;ROWS=ROWS*16
	 sub win_file_relative_starty,ax
         jmp short fvb_update
         fvb_up_ini:
         mov win_files_start_element,0
         mov win_file_relative_starty,0
         jmp short fvb_update
         fvb_down:
         mov ax,FILES_ROWS
   	 add win_files_start_element,ax
         mov cl,4
         shl ax,cl
	 add win_file_relative_starty,ax
         mov ax,win_files_start_element
         add ax,FILES_ROWS
         cmp ax,struc_file_elements_count
         jb fvb_update
         mov ax,struc_file_elements_count
         sub ax,FILES_ROWS
         mov win_files_start_element,ax
         mov bx,16
         mul bx
         mov win_file_relative_starty,ax
	 mov ax,word ptr mouse_struc_data_filesvb+6
	 mov word ptr mouse_struc_data_filesvbf+6,ax
         sub ax,filesvb_float_lenght
	 mov word ptr mouse_struc_data_filesvbf+2,ax
         jmp short fvb_draw
         fvb_update:
         ;begin calculate new bar pos
	 mov ax,word ptr mouse_struc_data_filesvb+6 ; totalbar
	 sub ax,word ptr mouse_struc_data_filesvb+2
	 sub ax,filesvb_float_lenght
	 mov bx,1000
         mul bx
         mov cx,struc_file_elements_count
         sub cx,FILES_ROWS
         div cx
         mov cx,win_files_start_element
         mul cx
         div bx
	 add ax,word ptr mouse_struc_data_filesvb+2
	 mov word ptr mouse_struc_data_filesvbf+2,ax
         add ax,filesvb_float_lenght
	 mov word ptr mouse_struc_data_filesvbf+6,ax
         ;end calculate new bar pos
         fvb_draw:
         call draw_files_vertical_bar_scroll
	 call draw_files
	filesvb_exit:
; * * * into FILES vertical bar down button ?
	cmp mouse_struc_current,22
	je intoFvbdownbutton
           cmp fvbdown_sw1,off
           jne fvddown_ok
	   jmp fvbdown_pressed_out
               fvddown_ok:
	       mov fvbdown_sw1,off
	       mov win_icon_addr,offset icon_arrow_down1
	       jmp s000
	intoFvbdownbutton:
	cmp fvbdown_sw1,off
	jne fvbdownout_x
        jmp fvbdownout
            fvbdownout_x:
            cmp mouse_updated_button_left,on
	    je s009
            mov fvbdown_sw1,off
            mov win_icon_addr,offset icon_arrow_down1
            jmp s000
            s009:
	    mov ax,win_files_start_element
	    add ax,FILES_ROWS
	    cmp ax,struc_file_elements_count
	    jb fvddown_ok3
	    mov ax,mouse_struc_data_filesvbf+6
	    cmp ax,mouse_struc_data_filesvb+6
	    jb bar_down_one_pixel
	    jmp fvbdown_pressed_out
	    bar_down_one_pixel:
	    inc mouse_struc_data_filesvbf+2
	    inc mouse_struc_data_filesvbf+6
            call draw_files_vertical_bar_scroll
	    call draw_files
            jmp short fvbdown_pressed_out
            fvddown_ok3:
   	    inc win_files_start_element
	    add win_file_relative_starty,16
            ;begin calculate new bar pos
	    mov ax,word ptr mouse_struc_data_filesvb+6 ; totalbar
	    sub ax,word ptr mouse_struc_data_filesvb+2
	    sub ax,filesvb_float_lenght
	    mov bx,1000
            mul bx
            mov cx,struc_file_elements_count
	    sub cx,FILES_ROWS
            div cx
            mov cx,win_files_start_element
            mul cx
	    div bx
	    add ax,word ptr mouse_struc_data_filesvb+2
	    mov word ptr mouse_struc_data_filesvbf+2,ax
            add ax,filesvb_float_lenght
	    mov word ptr mouse_struc_data_filesvbf+6,ax
            ;end calculate new bar pos
            mov filesvb_float_ini_y1_latest,0ffffh ;enable refresh screen
            call draw_files_vertical_bar_scroll
	    call draw_files
	    jmp short fvbdown_pressed_out
        fvbdownout:
        cmp mouse_updated_button_left,on
	jne fvbdown_pressed_out
        mov fvbdown_sw1,on
	mov win_icon_addr,offset icon_arrow_down2
   s000:mov win_relative_x1,623
	mov win_relative_y1,427
	call draw_icon
      fvbdown_pressed_out:
; * * * into vertical bar (float)
	cmp mouse_struc_current,19
	jne vbf222
	jmp vbfloat
	vbf222:
	   cmp filesvb_float_sw1,on
           jne g44
               cmp mouse_updated_button_left,on
               je vbf_n10
               mov filesvb_float_sw1,off
               mov filesvb_float_sw2,off
               mov win_color_bar,blue_light
               call draw_files_vertical_bar_scroll
               call draw_files
           g44:jmp vbfloat_out
           vbf_n10:
           mov ax,mouse_updated_y
           sub ax,filesvb_float_rel_y
	   cmp ax,word ptr mouse_struc_data_filesvb+2
           jg xx6
	       mov ax,word ptr mouse_struc_data_filesvb+2
	       mov word ptr mouse_struc_data_filesvbf+2,ax
               add ax,filesvb_float_lenght
	       mov word ptr mouse_struc_data_filesvbf+6,ax
               jmp short xx7a
           xx6:
           mov ax,mouse_updated_y
           sub ax,filesvb_float_rel_y
           add ax,filesvb_float_lenght
	   cmp ax,word ptr mouse_struc_data_filesvb+6
           jb xx7
	       mov ax,word ptr mouse_struc_data_filesvb+6
	       mov word ptr mouse_struc_data_filesvbf+6,ax
               sub ax,filesvb_float_lenght
	       mov word ptr mouse_struc_data_filesvbf+2,ax
               jmp short xx7a
           xx7:
               mov ax,mouse_updated_y
               sub ax,filesvb_float_rel_y
	       mov word ptr mouse_struc_data_filesvbf+2,ax
               add ax,filesvb_float_lenght
	       mov word ptr mouse_struc_data_filesvbf+6,ax
           xx7a:
	   mov ax,word ptr mouse_struc_data_filesvbf+2
           cmp filesvb_float_ini_y,ax
           jne vbf_n3
           jmp vbfloat_out
           vbf_n3:
                mov filesvb_float_ini_y,ax
                mov ax,struc_file_elements_count
                sub ax,FILES_ROWS
                inc ax
                mov bx,1000
                mul bx
		mov cx,word ptr mouse_struc_data_filesvb+6
		sub cx,word ptr mouse_struc_data_filesvb+2
                sub cx,filesvb_float_lenght
                div cx
		mov cx,word ptr mouse_struc_data_filesvbf+2
		sub cx,word ptr mouse_struc_data_filesvb+2
                mul cx
                div bx
                mov bx,ax
                mov win_files_start_element,bx
                mov bx,16
                mul bx
                mov win_file_relative_starty,ax
                mov win_color_bar,blue_push
                call draw_files_vertical_bar_scroll
                call draw_files
                mov win_color_bar,blue_light
                jmp vbfloat_out
	vbfloat:
	cmp filesvb_float_sw2,on ; sw1=on when MOUSE OVER BAR + CLICK+sw2=on
        jne vbf_f03              ;        (mouse button is pressed)
        cmp mouse_updated_button_left,on
        je vbf_q10
        jmp vbfloat_out
        vbf_q10:
        mov filesvb_float_sw1,on
        mov filesvb_float_sw2,off
        jmp vbf001               ; sw2=on when MOUSE OVER BAR + NO CLICK
vbf_f03:cmp filesvb_float_sw1,on ;        (condition for process movements)
        jne xf
        cmp mouse_updated_button_left,on
        je vbf007
        mov filesvb_float_sw1,off
        mov filesvb_float_sw2,off
        mov win_color_bar,blue_light
        call draw_files_vertical_bar_scroll
        call draw_files
        jmp short xf2
    xf: cmp mouse_updated_button_left,on
        je xf2
        mov filesvb_float_sw2,on
    xf2:jmp vbfloat_out
        vbf007:
        mov ax,mouse_updated_y
        cmp ax,filesvb_float_mouse_y_latest
        je xf2 ;exit
        sub ax,filesvb_float_rel_y
	cmp ax,word ptr mouse_struc_data_filesvb+2
        jg xx8
	    mov ax,word ptr mouse_struc_data_filesvb+2
	    mov word ptr mouse_struc_data_filesvbf+2,ax
            add ax,filesvb_float_lenght
	    mov word ptr mouse_struc_data_filesvbf+6,ax
            jmp short xx9a
        xx8:
        mov ax,mouse_updated_y
        sub ax,filesvb_float_rel_y
        add ax,filesvb_float_lenght
	cmp ax,word ptr mouse_struc_data_filesvb+6
        jbe xx9
	    mov ax,word ptr mouse_struc_data_filesvb+6
	    mov word ptr mouse_struc_data_filesvbf+6,ax
            sub ax,filesvb_float_lenght
	    mov word ptr mouse_struc_data_filesvbf+2,ax
            jmp short xx9a
        xx9:
            mov ax,mouse_updated_y
            sub ax,filesvb_float_rel_y
	    mov word ptr mouse_struc_data_filesvbf+2,ax
            add ax,filesvb_float_lenght
	    mov word ptr mouse_struc_data_filesvbf+6,ax
        xx9a:
	mov ax,word ptr mouse_struc_data_filesvbf+2
        cmp filesvb_float_ini_y,ax
        jne vbf_n39
        jmp vbfloat_out
        vbf_n39:
             mov filesvb_float_ini_y,ax
             mov ax,struc_file_elements_count
             sub ax,FILES_ROWS
             inc ax
             mov bx,1000
             mul bx
	     mov cx,word ptr mouse_struc_data_filesvb+6
	     sub cx,word ptr mouse_struc_data_filesvb+2
             sub cx,filesvb_float_lenght
             div cx
	     mov cx,word ptr mouse_struc_data_filesvbf+2
	     sub cx,word ptr mouse_struc_data_filesvb+2
             mul cx
             div bx
             mov bx,ax
             mov win_files_start_element,bx
             mov bx,16
             mul bx
             mov win_file_relative_starty,ax
             mov win_color_bar,blue_push
             call draw_files_vertical_bar_scroll
             call draw_files
             mov win_color_bar,blue_light
             jmp short vbfloat_out
      vbf001:mov ax,mouse_updated_y
	     mov filesvb_float_mouse_y_latest,ax
	     sub ax,word ptr mouse_struc_data_filesvbf+2
             mov filesvb_float_rel_y,ax
             mov win_color_bar,blue_push
             call draw_files_vertical_bar_scroll
             call draw_files
             mov win_color_bar,blue_light
      vbfloat_out:
jmp exploring
codesegment ENDs
END start